#region license
# This file is part of Grawlix.
# 
# Grawlix is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# 
# Grawlix is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public
# License along with Grawlix.  If not, see
# <http://www.gnu.org/licenses/>.
#endregion

"""A structure specifying a row of text."""

namespace Grawlix.Services.Rendering
import Grawlix.Meta
import C5
import System
import System.Drawing.Color as Color

struct TextRun:
"""A group of text with the same style."""
	
	[Equality]
	private def Equality(rhs as TextRun):
	"""
	Equality testing.
	Returns: true if equal, else false.
	"""
		return (Run == rhs.Run and Tint == rhs.Tint and Font == rhs.Font)
	
	override def GetHashCode():
	"""
	Get a hash code based on current value.
	Returns: The hash code.
	"""
		return Run.GetHashCode() ^ Tint.GetHashCode() ^ Font.GetHashCode()
	
	override def ToString():
	"""
	Get a string representation for this object.
	Returns: A string representation for this object.
	"""
		return "TextRun ${_font}"
	
	Run as IList[of Glyph]:
	"""Get the run itself as a sequence of glyphs."""
		get:
			if _run is null:
				_run = ArrayList[of Glyph]()
			return _run
	
	private _run as ArrayList[of Glyph]
	"""The series of glyphs."""
	
	[property(Font)]
	private _font as IFontResource
	"""The font to render with."""
	
	[property(Tint)]
	private _tint as Color
	"""The color to render the text."""
